﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using IQKS.AWP.DataAccessLayer;
using IQKS.AWP.BusinessObject;


namespace IQKS.AWP.BusinessAccessLayer
{
    public class ActivityMasterBAL
    {

        public DataSet GetActivityMaster()
        {
            DataSet objDs;
            try
            {
                objDs = new ActivityMasterDAL().GetActivityMaster(0);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

       //public ActivityMasterBO
        

        public ActivityMasterBO GetActivityMaster(params object[] param)
        {
           
            ActivityMasterBO objAMBo;
            try
            {
                
                objAMBo = new ActivityMasterBO();
                DataSet objDs;
                objDs = new ActivityMasterDAL().GetActivityMaster(param);
                if (objDs != null)
                {
                    DataTable objDt = objDs.Tables[0];
                    if (objDt != null)
                    {
                        objAMBo.ActivityID = Convert.ToInt32(objDt.Rows[0]["ActivityID"]);
                        objAMBo.ActivityTypeID = Convert.ToInt32(objDt.Rows[0]["ActivityTypeID"]);
                        
                        objAMBo.ActivityName = Convert.ToString(objDt.Rows[0]["ActivityName"]);
                        objAMBo.ActivityCode = Convert.ToString(objDt.Rows[0]["ActivityCode"]);
                        objAMBo.IsActive = Convert.ToBoolean(objDt.Rows[0]["IsActive"]);
                    }
                    else
                    {
                        objAMBo = null;
                    }
                }

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objAMBo;
        }


        public object SetActivityMaster(ActivityMasterBO param)
        {
            try
            {
                return new ActivityMasterDAL().SetActivityMaster(param);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(ex.Message);
            }
        }


        public DataSet GetActivityByActivityType(params object[] param)
        {
            DataSet objDs;
            try
            {
                objDs = new ActivityMasterDAL().GetActivityByActivityType(param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        //TODO SAVE IN Country Master BAL
        public DataSet GetCountryMasterActive()
        {
            DataSet objDs;
            try
            {
                objDs = new ActivityMasterDAL().GetCountryMasterActive();

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        //TODO Get CountryName From RegionID
        public DataSet GetCountryFromRegionMaster(params object[] param)
        {
            DataSet objDs;
            try
            {
                objDs = new CountryFromRegionMasterDAL().GetCountryFromRegionMaster(param);

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }

        public DataSet GetRegionMasterActive()
        {
            DataSet objDs;
            try
            {
                objDs = new ActivityMasterDAL().GetRegionMasterActive();

            }
            catch (Exception exception)
            {
                throw new ApplicationException(exception.Message);
            }
            return objDs;
        }
    }
}
